import pymysql

#创建数据库连接
db = pymysql.connect(
    host="localhost",
    port=3306,
    user="root",
    database="crawlerdemo",
    password="gl030513",
    charset="utf8"
)
#获取操作游标
cursor = db.cursor()
#使用execute方法执行SQL语句
cursor.execute("select * from m_stu")
print(cursor)
#获取一条数据，字符串
data =cursor.fetchone()
print(data)

#关掉游标
cursor.close()
#关掉数据库连接
db.close()
